package com.iteaj.network.test.client.line;

import com.iteaj.network.client.ClientProtocolHandle;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import java.time.Duration;
import java.time.Instant;

@Component
public class LineClientHandle implements InitializingBean, ClientProtocolHandle<LineClientRequestProtocol> {

    @Autowired
    private ThreadPoolTaskScheduler scheduler;

    @Override
    public void afterPropertiesSet() throws Exception {
        scheduler.scheduleAtFixedRate(() -> {
            new LineClientRequestProtocol().request();
        }, Instant.now().plusSeconds(5), Duration.ofSeconds(10));
    }

    @Override
    public Object business(LineClientRequestProtocol protocol) {
        return null;
    }
}
